<include file="Public/min-header"/>
<style type="text/css">
    select.form-control {
        display: initial;
        float: left;
    }

    .ajax_bradnlist {
        height: 318px;
        overflow: auto
    }

    .ajax_bradnlist ul {
        clear: both;
        padding-top: 10px
    }

    .ajax_bradnlist ul li {
        float: left;
        display: inline-flex;
        display: -moz-inline-flex;
        display: -webkit-inline-box;
        width: 20%;
        padding: 6px 0;
    }

    .table-bordered th:first-child {
        width: 8%
    }

    .table-bordered tbody tr td {
        vertical-align: middle
    }

    .form-control {
        resize: vertical
    }
</style>
<div class="wrapper">
    <include file="Public/breadcrumb"/>
    <section class="content">
        <div class="row">
            <div class="col-sm-12">
                <div class="box">
                    <div class="box-header">
                        <h3 class="box-title">增加分类</h3>
                    </div>
                    <!-- /.box-header -->
                    <form action="{:U('Goods/addEditCategory')}" method="post" class="form-horizontal"
                          id="category_form">
                        <div class="box-body">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">分类名称</label>
                                <div class="col-sm-6">
                                    <input type="text" placeholder="名称" class="form-control large" name="name"
                                           value="{$goods_category_info.name}">
                                    <span class="help-inline" style="color:#F00; display:none;" id="err_name"></span>
                                </div>
                            </div>

                            <div class="form-group">
                                <label0 class="control-label col-sm-2">上级分类</label0>

                                <div class="col-sm-3">
                                    <select name="parent_id_1" id="parent_id_1"
                                            onchange="get_category(this.value,'parent_id_2','0');"
                                            class="small form-control">
                                        <option value="0">顶级分类</option>
                                        <foreach name="cat_list" item="v">
                                            <option value="{$v[id]}">{$v[name]}</option>
                                        </foreach>
                                    </select>
                                </div>
                                <div class="col-sm-3">
                                    <select name="parent_id_2" id="parent_id_2" class="small form-control">
                                        <option value="0">请选择商品分类</option>
                                    </select>
                                </div>
                            </div>


                            <div class="form-group">
                                <label class="control-label col-sm-2">分类展示图片</label>

                                <div class="col-sm-10">
                                    <input onclick="GetUploadify(1,'image','category');" type="button" value="上传图片"/>
                                    <input type="text" value="{$goods_category_info.image}" name="image" id="image"
                                           class="form-control large" readonly="readonly"
                                           style="width:500px;display:initial;"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-sm-2">显示排序</label>
                                <div class="col-sm-1">
                                    <input type="text" placeholder="50" class="form-control large" name="sort_order"
                                           value="{$goods_category_info.sort_order}"/>
                                    <span class="help-inline" style="color:#F00; display:none;"
                                          id="err_sort_order"></span>
                                </div>
                            </div>

                            <div class="box-footer">
                                <input type="hidden" name="id" value="{$goods_category_info.id}">
                                <button type="reset" class="btn btn-primary pull-left"><i class="icon-ok"></i>重填
                                </button>
                                <button type="button"
                                        onclick="ajax_submit_form('category_form','{:U('Goods/addEditCategory?is_ajax=1')}');"
                                        class="btn btn-primary pull-right"><i class="icon-ok"></i>提交
                                </button>
                            </div>
                    </form>
                </div>
            </div>
        </div>
    </section>
</div>
<script>

    /** 以下是编辑时默认选中某个商品分类*/
    $(document).ready(function () {
    <
        if condition = "$level_cat['2'] gt 0" >
            // 如果当前是二级分类就让一级父id默认选中
            $("#parent_id_1").val('{$level_cat[1]}');
        get_category('{$level_cat[1]}', 'parent_id_2', '0');
    <
        /if>
        <
        if condition = "$level_cat['3'] gt 0" >
            // 如果当前是三级分类就一级和二级父id默认 都选中
            $("#parent_id_1").val('{$level_cat[1]}');
        get_category('{$level_cat[1]}', 'parent_id_2', '{$level_cat[2]}');
    <
        /if>
    });

    // 将品牌滚动条里面的 对应分类移动到 最上面
    //javascript:document.getElementById('category_id_3').scrollIntoView();
    var typeScroll = 0;

    function spec_scroll(o) {
        var id = $(o).val();
        if (!$('#type_id_' + id).is('h5')) {
            return false;
        }
        $('#ajax_brandList').scrollTop(-typeScroll);
        var sp_top = $('#type_id_' + id).offset().top; // 标题自身往上的 top
        var div_top = $('#ajax_brandList').offset().top; // div 自身往上的top
        $('#ajax_brandList').scrollTop(sp_top - div_top); // div 移动
        typeScroll = sp_top - div_top;
    }
</script>

</body>
</html>